namespace XRM.Security.DataAccess.Context
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class AddPCColumns : DbMigration
    {
        public override void Up()
        {
            Sql("delete from UserPC");
            Sql("delete from PC");

            CreateTable(
                "dbo.PCSticker",
                c => new
                    {
                        PCStickerId = c.Int(nullable: false, identity: true),
                        StickerNumber = c.String(nullable: false, maxLength: 50),
                        PCId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.PCStickerId)
                .ForeignKey("dbo.PC", t => t.PCId, cascadeDelete: true)
                .Index(t => t.PCId);
            
            AddColumn("dbo.PC", "SerialNumber", c => c.String(nullable: false, maxLength: 50));
            AddColumn("dbo.PC", "PCHost", c => c.String(nullable: false, maxLength: 250));
            DropColumn("dbo.PC", "PCName");
        }
        
        public override void Down()
        {
            AddColumn("dbo.PC", "PCName", c => c.String(nullable: false, maxLength: 100));
            DropForeignKey("dbo.PCSticker", "PCId", "dbo.PC");
            DropIndex("dbo.PCSticker", new[] { "PCId" });
            DropColumn("dbo.PC", "PCHost");
            DropColumn("dbo.PC", "SerialNumber");
            DropTable("dbo.PCSticker");
        }
    }
}
